package com.gxy.learn.design.model.behaviour.interpreter;

/**
 * @description: 减法
 * @author: gaoxueyong
 * @Date: 2022/11/9 10:53
 */
public class Minus extends AbstractExpression{

    private AbstractExpression left;
    private AbstractExpression right;

    public Minus(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }

    /**
     * 解释器
     *
     * @param context
     * @return void
     * @Author gaoxueyong
     * @Date 10:50 上午 2022/11/9
     * @Param [context]
     */
    @Override
    int interprete(Context context) {
        return left.interprete(context)-right.interprete(context);
    }


    @Override
    public String toString() {
        return String.format("(%s-%s)",left.toString(),right.toString());
    }
}
